﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Reference.Tools.CodeTransformer
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog of = new OpenFileDialog();
            bool? result = of.ShowDialog();
            if (result.HasValue ? result.Value : false)
            {
                var lines = File.ReadAllLines(of.FileName);
                StringBuilder sb = new StringBuilder();
                foreach (string line in lines)
                {
                    for (int i = 0; i < line.Length; i++)
                    {
                        if (line[i] == '\t')
                        {
                            sb.Append("\\t");
                        }
                        else
                        {
                            sb.Append(line[i]);
                        }
                    }
                    sb.Append("\\n");
                }
                ResultTextBox.Text = sb.ToString();
            }
        }
    }
}
